sudo apt-get update 
sudo apt-get install -y --no-install-recommends build-essential cmake git libgoogle-glog-dev libprotobuf-dev protobuf-compiler python-dev python-pip 
sudo pip install numpy protobuf
sudo apt-get install -y --no-install-recommends libgflags-dev

sudo apt-get install -y --no-install-recommends libgtest-dev libiomp-dev libleveldb-dev liblmdb-dev libopencv-dev libopenmpi-dev libsnappy-dev openmpi-bin openmpi-doc python-pydot 
sudo -H pip install --upgrade pip 
##这里更新一下pip，否则后面pip安装jupyter有可能会报错 
sudo pip install flask future graphviz hypothesis jupyter matplotlib pydot python-nvd3 pyyaml requests scikit-image scipy setuptools six tornado

git clone --recursive https://github.com/pytorch/pytorch.git 
cd pytorch
git submodule update --init
mkdir build
cd build 
cmake -D USE_NATIVE_ARCH=ON .. 
make
sudo make install
sudo ldconfig

cd ~
python -c 'from caffe2.python import core' 2>/dev/null && echo "Success" || echo "Failure"
python -c 'from caffe2.python import workspace; print(workspace.NumCudaDevices())'

